/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.xd.controller;

import java.util.Collection;
import java.util.List;

import com.xy.biz.xd.domain.bo.DocumentFlowCancelRequestFlowBO;
import com.xy.biz.xd.domain.req.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xy.lang.domain.Page;
import com.xy.lang.domain.Result;
import com.xy.lang.validation.SaveChecks;
import com.xy.lang.validation.UpdateChecks;
import com.xy.lang.validation.annotation.Validatable;

import com.xy.biz.xd.domain.resp.GetDocumentFlowCancelRequestFlowResponse;
import com.xy.biz.xd.domain.query.DocumentFlowCancelRequestFlowQuery;
import com.xy.biz.xd.domain.converter.DocumentFlowCancelRequestFlowConverter;
import com.xy.biz.xd.service.DocumentFlowCancelRequestFlowService;

/**
 * 
 * 
 * @author zgy
 * @date 2021-6-17
 */
@Api(tags = "取消申请服务")
@Slf4j
@RequestMapping("/api/xd/document_flow_cancel_request")
@RestController
public class DocumentFlowCancelRequestFlowController {

	@Autowired
	private DocumentFlowCancelRequestFlowService documentFlowCancelRequestFlowService;


	@ApiOperation("申请")
	@Validatable(groups = {UpdateChecks.class})
	@PostMapping(value = "/apply")
	public Result<?> applyDocumentFlowCancelRequestFlow(@RequestBody SaveDocumentFlowCancelRequestFlowRequest request) {
		return documentFlowCancelRequestFlowService.saveDocumentFlowCancelRequestFlow(request);
	}

	@ApiOperation("审核")
	@Validatable(groups = {UpdateChecks.class})
	@PostMapping(value = "/audit")
	public Result<?> auditDocumentFlowCancelRequestFlow(@RequestBody DocumentFlowCancelRequestFlowRequest request) {
		return documentFlowCancelRequestFlowService.auditDocumentFlowCancelRequestFlow(request);
	}
	/*@Validatable(groups = {SaveChecks.class})
	@PostMapping(value = "/save")
	public Result<?> saveDocumentFlowCancelRequestFlow(@RequestBody SaveDocumentFlowCancelRequestFlowRequest request) {
		documentFlowCancelRequestFlowService.saveDocumentFlowCancelRequestFlow(DocumentFlowCancelRequestFlowConverter.toBO(request));
		return Result.success();
	}
	
	@Validatable(groups = {SaveChecks.class})
	@PostMapping(value = "/save_all")
	public Result<?> saveAllDocumentFlowCancelRequestFlow(@RequestBody Collection<SaveDocumentFlowCancelRequestFlowRequest> collection) {
		documentFlowCancelRequestFlowService.saveAllDocumentFlowCancelRequestFlow(DocumentFlowCancelRequestFlowConverter.toBO(collection));
		return Result.success();
	}
	
	@Validatable(groups = {UpdateChecks.class})
	@PostMapping(value = "/update")
	public Result<?> updateDocumentFlowCancelRequestFlow(@RequestBody SaveDocumentFlowCancelRequestFlowRequest request) {
		documentFlowCancelRequestFlowService.updateDocumentFlowCancelRequestFlow(DocumentFlowCancelRequestFlowConverter.toBO(request));
		return Result.success();
	}
	
	@Validatable
	@PostMapping(value = "/delete")
	public Result<?> deleteDocumentFlowCancelRequestFlow(@RequestBody GetDocumentFlowCancelRequestFlowRequest request) {
		documentFlowCancelRequestFlowService.deleteDocumentFlowCancelRequestFlow(request.getDocumentFlowCancelRequestFlowId());
		return Result.success();
	}
	
	@Validatable
	@PostMapping(value = "/get")
	public Result<GetDocumentFlowCancelRequestFlowResponse> getDocumentFlowCancelRequestFlow(@RequestBody GetDocumentFlowCancelRequestFlowRequest request) {
		return Result.success(DocumentFlowCancelRequestFlowConverter.toResponse(documentFlowCancelRequestFlowService.getDocumentFlowCancelRequestFlow(request.getDocumentFlowCancelRequestFlowId())));
	}
	
	@PostMapping(value = "/list_by_ids")
	public Result<List<GetDocumentFlowCancelRequestFlowResponse>> listDocumentFlowCancelRequestFlowById(@RequestBody Collection<Long> collection) {
		return Result.success(DocumentFlowCancelRequestFlowConverter.toResponse(documentFlowCancelRequestFlowService.listDocumentFlowCancelRequestFlowById(collection)));
	}
	
	@PostMapping(value = "/list")
	public Result<List<GetDocumentFlowCancelRequestFlowResponse>> listDocumentFlowCancelRequestFlow(@RequestBody ListDocumentFlowCancelRequestFlowRequest request) {
		return Result.success(DocumentFlowCancelRequestFlowConverter.toResponse(documentFlowCancelRequestFlowService.listDocumentFlowCancelRequestFlow(DocumentFlowCancelRequestFlowConverter.toQuery(request))));
	}
	
	@PostMapping(value = "/count")
	public Result<Integer> countDocumentFlowCancelRequestFlow(@RequestBody ListDocumentFlowCancelRequestFlowRequest request) {
		return Result.success(documentFlowCancelRequestFlowService.countDocumentFlowCancelRequestFlow(DocumentFlowCancelRequestFlowConverter.toQuery(request)));
	}
	
	@PostMapping(value = "/page")
	public Result<Page<GetDocumentFlowCancelRequestFlowResponse>> pageDocumentFlowCancelRequestFlow(@RequestBody ListDocumentFlowCancelRequestFlowRequest request) {
		DocumentFlowCancelRequestFlowQuery query = DocumentFlowCancelRequestFlowConverter.toQuery(request);
		List<GetDocumentFlowCancelRequestFlowResponse> list = DocumentFlowCancelRequestFlowConverter.toResponse(documentFlowCancelRequestFlowService.listDocumentFlowCancelRequestFlow(query));
		int count = documentFlowCancelRequestFlowService.countDocumentFlowCancelRequestFlow(query);
		return Result.success(new Page<>(list, count));
	}*/
	
}
